package com.llc.station.kcp.ui.core.component;

import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;


/**
 * 作者 zxj<br>
 * 时间 2017/9/13 19:22
 * 说明 ...
 */
public class PiceText extends StackPane {

    private double piceWidth;
    private Circle circle;
    private Label label = new Label("");

    private int fontSize = 15;
    private Color fgColor = Color.rgb(223,223,223);
    private Color bgColor = Color.rgb(1,1,1);


    public PiceText(double piceWidth) {
        this.piceWidth = piceWidth;
        init();
    }

    public PiceText(double piceWidth, Node... children) {
        super(children);
        this.piceWidth = piceWidth;
        init();
    }

    private void init(){
        this.setPrefWidth(piceWidth);
        this.setPrefHeight(piceWidth);
        circle = new Circle();
        circle.setCenterX(piceWidth / 2);
        circle.setCenterY(piceWidth / 2);
        circle.setRadius(piceWidth / 2);

        this.getChildren().add(circle);
        this.getChildren().add(label);
        initUI();
    }
    private void initUI(){
        this.circle.setStroke(bgColor);
        this.label.setTextFill(fgColor);
        label.setFont(new Font(fontSize));
    }

    public void setText(String text){
        label.setText(text);
        initUI();
    }

    public void setBgColor(Color color){
        this.bgColor = color;
        initUI();
    }
    public void setFgColor(Color color){
        this.fgColor = color;
        initUI();
    }



}
